﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR48Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR48Request))]
    public class RR48RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR48Request clazz;
        
        public RR48RequestSerializer(IRR48Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusynnikp");
            if (clazz.Isikusynnikp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusynnikp))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusynnikp");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuperenimi");
            if (clazz.Isikuperenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuperenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuperenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikueesnimi");
            if (clazz.Isikueesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikueesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikueesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikumaakond");
            if (clazz.Isikumaakond!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikumaakond))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikumaakond");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuvald");
            if (clazz.Isikuvald!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuvald))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuvald");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Request>Isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Request>Isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusynnikp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Request>Isikusynnikp");
                }
                clazz.Isikusynnikp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusynnikp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Request>Isikusynnikp", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuperenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Request>Isikuperenimi");
                }
                clazz.Isikuperenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuperenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Request>Isikuperenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikueesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Request>Isikueesnimi");
                }
                clazz.Isikueesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikueesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Request>Isikueesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikumaakond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Request>Isikumaakond");
                }
                clazz.Isikumaakond = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikumaakond")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Request>Isikumaakond", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuvald") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Request>Isikuvald");
                }
                clazz.Isikuvald = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuvald")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Request>Isikuvald", Reader.LocalName);
            }
        }
    }
}
